            <div>
				<ul class="breadcrumb">
					<li>
						<a href="<?php echo site_url("menu/survey"); ?>">Quản lý khảo sát</a> / 
						<a href="<?php echo site_url("surveytype"); ?>">Loại khảo sát</a> / 
						<a href="<?php echo site_url("survey/index/" . $st->survey_type_id); ?>"><?php echo $st->survey_type_name ?></a> / 
						<a href="<?php echo site_url("survey/details/" . $survey->survey_id); ?>"><?php echo $survey->survey_name ?></a> / 
						Sửa phiếu khảo sát
					</li>
				</ul>
			</div>
			<div class="row-fluid">
				<div class="box span12">
					<div class="box-header well">
						<h2><i class="icon-pencil"></i> Bước 3: Thiết kế bộ câu hỏi</h2>
						<div class="box-icon">
							<a href="#" class="btn btn-minimize btn-round"><i class="icon-chevron-up"></i></a>
						</div>
					</div>
					<div class="box-content">
						<form class="form-horizontal" method="post">
							<fieldset>
								<div class="control-group">
									<label class="control-label" for="content">Câu hỏi</label>
									<div class="controls">
                                        <input name="qid" type="hidden" />
										<input class="input-file uniform_on span8" id="content" name="content" type="text"/>
                                        <?php echo form_error('content'); ?>
									</div>
								</div>
								<div class="control-group"> 
									<label class="control-label"></label>
									<div>
										<label class="checkbox inline">
											<input type="checkbox" id="required" name="required" value="true"/>Câu hỏi cần phải trả lời.
										</label>
									</div>
								</div>
								<div class="control-group"> 
									<label class="control-label"></label>
									<div>
										<label class="checkbox inline">
											<input type="checkbox" id="shide" name="shide" value="true"/>Câu hỏi ẩn.
										</label>
									</div>
								</div>
								<div class="control-group">
									<label class="control-label" for="vorder">Thứ tự sắp xếp</label>
									<div class="controls">
										<select id="vorder" name="vorder" data-rel="chosen">
                                            <?php for($i=1; $i<=$vorder; $i++){ ?>
											    <option value="<?php echo $i ?>"><?php echo $i ?></option>
                                            <?php };?>
                                            <option value="<?php echo $vorder+1 ?>" selected="true">Cuối cùng</option>
										</select>
                                        <?php echo form_error('vorder'); ?>
									</div>
								</div>
								<div class="control-group">
									<label class="control-label" for="otype">Câu trả lời dạng</label>
									<div class="controls">
										<select id="otype" name="otype" data-rel="chosen">
											<option value="r">Chỉ chọn một</option>
											<option value="c">Nhiều lựa chọn</option>
                                            <option value="t">Text</option>
										</select>
										<?php echo form_error('otype'); ?>
									</div>
								</div>
								<div class="control-group">
									<label class="control-label" for="vstyle">Thể hiện</label>
									<div class="controls">
										<select id="vstyle" name="vstyle" data-rel="chosen">
											<option value="1">1 cột</option>
											<option value="2">2 cột</option>
										</select>
                                        <?php echo form_error('vstyle'); ?>
									</div>
								</div>
                                <div id="answer-group">
                                    <div id="normal-answer-group"></div>
                                    <div id="other-answer-group"></div>
                                    <?php echo $check_number_of_answer_templates;?>
                                </div>
								<div class="control-group">
									<div class="controls">
                                        <div class="btn-group">
                							<a href="#" class="btn btn-setting" id="addanswer">Thêm câu trả lời</a>
                							<button class="btn dropdown-toggle" data-toggle="dropdown"><span class="caret"></span></button>
                							<ul class="dropdown-menu">
                								<li><a href="#" id="addotheranswer">Thêm lựa chọn khác</a></li>
                								<li><a href="#" id="addprovinceanswer" style="display: none;">Thêm lựa chọn tỉnh/thành phố</a></li>
                							</ul>
                						</div>
									</div>
								</div>
								<div class="form-actions">
									<button type="submit" class="btn btn-primary" name="submit" value="addquestion">Lưu</button>
									<button type="submit" class="btn btn-primary" name="submit" value="next">Tiếp bước 4</button>
									<a class="btn" href="<?php echo site_url("survey/edit_step2");?>">Quay lại bước 2</a>
								</div>
							</fieldset>
						</form>
					</div>
				</div><!--/span-->
				
				<!--questions-->
				<div class="row-fluid">
					<div class="box span12">
						<div class="box-header well">
							<h2><i class="icon-list-alt"></i> Danh sách câu hỏi</h2>
							<div class="box-icon">
								<a href="#" class="btn btn-minimize btn-round"><i class="icon-chevron-up"></i></a>
							</div>
						</div>
						<div class="box-content">
							<!--questions-->
                            <?php $i=0; foreach($qlist as $q){ ?>
							<div class="row-fluid">
								<div class="box span12">
									<div class="box-header well">
										<h3>
                                            Câu hỏi <?php echo $q->view_order.': '.$q->content; if($q->required){?>
                                            <span class="icon icon-red icon-star-on">
                                            <?php };?>
                                        </h3>
										<div class="box-icon">
											<a href="#" class="btn btn-minimize btn-round"><i class="icon-chevron-up"></i></a>
										</div>
									</div>
									<div class="box-content">
                                        <?php foreach($atlist[$i] as $at){ ?>
    										<div class="controls">
                                                <?php if($at->option_type=='r '){ ?>
        											<label class="radio">
        												<input name="<?php echo $i; ?>" type="radio"/>
        												<?php echo $at->label; ?>
        											</label>
                                                <?php } else if($at->option_type=='c '){ ?>
        											<label class="checkbox">
        												<input type="checkbox"/>
        												<?php echo $at->label; ?>
        											</label>
                                                <?php } else if($at->option_type=='t '){ ?>
                                                    <?php echo $at->label; ?>
    											    <input type="text" class="span4"/>
                                                <?php } else if($at->option_type=='rt'){ ?>
        											<label class="radio">
        												<input name="<?php echo $i; ?>" type="radio"/>
        												<?php echo $at->label; ?>
        											</label>
                                                    <input type="text" class="span4"/>
                                                <?php } else if($at->option_type=='ct'){ ?>
                                                    <label class="checkbox">
        												<input type="checkbox"/>
        												<?php echo $at->label; ?>
        											</label>
    											    <input type="text" class="span4"/>
                                                <?php } else if($at->option_type=='pr'){ ?>
													<?php echo $at->label; ?>
													<div class="input-append">
														<input type="text" class="span4"/>
														<select>
														<?php foreach($prlist as $pr){ ?>
															<option><?php echo $pr->province_name;?></option>
														<?php };?>
														</select>
													</div>
                                                <?php }; ?>
    										</div>
                                        <?php };?>
										<div class="form-actions">
                                            <form method="post">
    											<a class="btn btn-primary" href="<?php echo site_url("survey/edit_question/".$q->question_id);?>">Sửa</a>
    											<a href="#duplicateModal" data-toggle="modal" qid="<?php echo $q->question_id; ?>" qcontent="<?php echo $q->content; ?>" class="btn btn-success">Sao chép</a>
    											<a href="#deleteModal" data-toggle="modal" qid="<?php echo $q->question_id; ?>" qcontent="<?php echo $q->content; ?>" class="btn btn-danger">Xoá</a>
										    </form>
                                        </div>
									</div>
								</div>
							</div>
                            <?php $i++; }; ?>
							<!--/questions-->
						</div>
					</div><!--/span-->
				</div>
				<!--/question-->
            </div>
        <!-- Hidden dialog -->
        <!-- Popup delete question -->
		<div class="modal hide fade" id="deleteModal">
				<div class="modal-header">
					<button type="button" class="close" data-dismiss="modal">×</button>
					<h3>Xóa câu hỏi</h3>
				</div>
                <!-- <form class="form-horizontal"> -->
                <form class="form-horizontal" method="post">
    				<div class="modal-body">
    					<fieldset>
    						<div class="control-group">
                                Bạn có chấp nhận xoá câu hỏi <b><span id="deleteqcontent"></span></b> không?
                                <input id="deleteqid" name="deleteqid" type="hidden"/>
    						</div>
    					</fieldset>
    				</div>
    				<div class="modal-footer">
    					<a href="#" class="btn" data-dismiss="modal">Thóat</a>
    					<button type="submit" name="submit" value="deletequestion" class="btn btn-primary">Đồng ý</button>
    				</div>
                </form>
                <!-- </form> -->
		</div>
        <!-- Popup duplicate question -->
		<div class="modal hide fade" id="duplicateModal">
				<div class="modal-header">
					<button type="button" class="close" data-dismiss="modal">×</button>
					<h3>Sao chép câu hỏi</h3>
				</div>
                <!-- <form class="form-horizontal"> -->
                <form class="form-horizontal" method="post">
    				<div class="modal-body">
    					<fieldset>
    						<div class="control-group">
                                Bạn có muốn sao chép câu hỏi <b><span id="duplicateqcontent"></span></b> không?
                                <input id="duplicateqid" name="duplicateqid" type="hidden"/>
    						</div>
    					</fieldset>
    				</div>
    				<div class="modal-footer">
    					<a href="#" class="btn" data-dismiss="modal">Thóat</a>
    					<button type="submit" name="submit" value="duplicatequestion" class="btn btn-primary">Đồng ý</button>
    				</div>
                </form>
                <!-- </form> -->
		</div>
    <!-- Placed at the end of the document so the pages load faster -->
    <!-- Internal Script -->
    <script type="text/javascript">
        $(document).ready(function(){
            //index of added answer
            var index = 0;
            
            //Event of add answer button
            $('#addanswer').click(function(){
				//Get current option type
                var otype = $('#otype').val();
                $.get('add_answer_template/' + otype + '/' + index, function(data, result){
                    if(result=='success')
                        $('#normal-answer-group').append(data);
                });
				index++;
            });
            //Event of add other answer button
            $('#addotheranswer').click(function(){
                var otype = $('#otype').val() + 't';
				$.get('add_answer_template/' + otype + '/' + index, function(data, result){
                    if(result=='success')
                        $('#other-answer-group').html(data);
                });
				index++;
            });
            //Event of add province answer button
			$('#addprovinceanswer').click(function(){
				var otype = 'pr';
                $.get('add_answer_template/' + otype + '/' + index, function(data, result){
                    if(result=='success')
                        $('#normal-answer-group').append(data);
                });
				index++;
			});
            //Event of combobox option type
            $('#otype').change(function(){
                var otype = $('#otype option:selected').val();
                
                $(".input-append [type='radio']").remove();
                $(".input-append [type='checkbox']").remove();
                if(otype=='r'){
					//remove province answer
					$("div[type='pr']").remove();
                    $("#answer-group .input-append").prepend("<input disabled='true' type='radio'>");
					//change option type of answer template
					$("#answer-group input[value='c']").val('r');
					$("#answer-group input[value='ct']").val('rt');
					$("#answer-group input[value='t']").val('r');
					
                    $('#addotheranswer').show();
                    $('#addprovinceanswer').hide();
                }else if(otype=='c'){
					//remove province answer
					$("div[type='pr']").remove();
                    $("#answer-group .input-append").prepend("<input disabled='true' type='checkbox'>");
					//change option type of answer template
					$("#answer-group input[value='r']").val('c');
					$("#answer-group input[value='rt']").val('ct');
					$("#answer-group input[value='t']").val('c');
					
                    $('#addotheranswer').show();
                    $('#addprovinceanswer').hide();
                }else if(otype=='t'){
					//remove 'other' answer
                    $('#other-answer-group').html('');
					//change option type of answer template
					$("#answer-group input[value='r']").val('t');
					$("#answer-group input[value='c']").val('t');
					
                    $('#addotheranswer').hide();
                    $('#addprovinceanswer').show();
                }
            });
            //Event of Delete question button
            $('a[href="#deleteModal"]').click(function(){
                $('#deleteqid').val($(this).attr("qid"));
                $('#deleteqcontent').html($(this).attr("qcontent"));
            });
            //Event of Duplicate question button
            $('a[href="#duplicateModal"]').click(function(){
                $('#duplicateqid').val($(this).attr("qid"));
                $('#duplicateqcontent').html($(this).attr("qcontent"));
            });
        });
    </script>
    <!-- End Internal Script -->